package org.graduates.webapp.actions.file;

import java.util.Comparator;
import java.util.Hashtable;

@SuppressWarnings("rawtypes")
public class SizeComparator implements Comparator<Hashtable> {

	public int compare(Hashtable a, Hashtable b) {
		Hashtable hashA = a;
		Hashtable hashB = b;
		if (((Boolean)hashA.get("is_dir")) && !((Boolean)hashB.get("is_dir"))) {
			return -1;
		} else if (!((Boolean)hashA.get("is_dir")) && ((Boolean)hashB.get("is_dir"))) {
			return 1;
		} else {
			if (((Long)hashA.get("filesize")) > ((Long)hashB.get("filesize"))) {
				return 1;
			} else if (((Long)hashA.get("filesize")) < ((Long)hashB.get("filesize"))) {
				return -1;
			} else {
				return 0;
			}
		}
	}

}
